const cityDao = require('../dao/city');

const config = require('../config').config;

const Response = require('../entity/http/Response');

const cityService = {
    async getAllProvince(reqId) {
        let result;
        try {
            let dbResult = await cityDao.getAllProvince(reqId);
            result = new Response().success(dbResult);
        } catch (err) {
            result = new Response().fail(500, "获取所有省份失败");
        }
        return result;
    },
    async getCitysByProvinceId(reqId, provinceId) {
        let result;
        try {
            let dbResult = await cityDao.getCitysByProvinceId(reqId, provinceId);
            result = new Response().success(dbResult);
        } catch (err) {
            result = new Response().fail(500, "获取某省份所有城市失败");
        }
        return result;
    }
};

module.exports = cityService;